Skip to content

Add modifier-only chord and double-tap modifier shortcuts on macOS#30

Merged
LeydenJar merged 4 commits into
mainfrom
claude/add-keyboard-shortcuts-gFUf3
May 21, 2026
Merged

Add modifier-only chord and double-tap modifier shortcuts on macOS#30
LeydenJar merged 4 commits into
mainfrom
claude/add-keyboard-shortcuts-gFUf3

Conversation

@GuilhermeVozniak
Copy link
Copy Markdown
Collaborator

Summary

  • Implements two new macOS-specific shortcut surfaces via a new CGEventTap-based backend (MacOsChordTap):
    • Modifier-only chord: e.g. Cmd+Opt held together with no other key, fires once on the press edge
    • Double-tap modifier: e.g. tap Cmd twice within ~350ms, fires on the second press
  • Adds parsing logic to recognize "Cmd+Opt" (modifier-only) and "DoubleTap+Cmd" (double-tap) combo strings and route them to the chord backend instead of the standard global-shortcut plugin
  • Updates the hotkey capture UI (HotkeyInput) to detect and emit these new combo types during recording
  • Adds tauri-plugin-autostart integration for app launch-on-login toggle in Settings and Onboarding
  • Changes the cancel-recording hotkey default from Cmd+Esc to bare Esc (now supported via permissive parser) and adds validation/registration lifecycle management

Test plan

  • Unit tests added for modifier-only and double-tap parsing (parse.rs)
  • Unit tests added for chord runtime state machine (macos_chord.rs)
  • Unit tests added for hotkey capture UI chord detection (HotkeyInput.test.tsx)
  • Integration tests updated for cancel-hotkey lifecycle (useHotkeyRecording.test.tsx, SettingsRecording.test.tsx, OnboardingScreen.test.tsx)
  • Manual smoke test: verified modifier-only chord fires once when exact set is held, double-tap fires on second press within window, non-modifier keypress invalidates in-flight sequence

Documentation update obligations

  • New Tauri command (register_cancel_hotkey, unregister_cancel_hotkey, validate_cancel_hotkey) → docs/architecture.md (command surface section)
  • New macOS-specific shortcut surfaces (modifier-only chord, double-tap) → docs/architecture.md (shortcut backend section)
  • New platform feature (autostart) → docs/permissions.md (if applicable) or docs/architecture.md

Breaking changes

None. The new combo types are additive; existing standard combos continue to work unchanged.

https://claude.ai/code/session_01AD2Gcj4j75xvaJb9oFpyCJ

claude added 4 commits May 18, 2026 23:33
The cancel-recording hotkey now accepts bare keys like Esc by going
through a permissive parser and being registered globally only while
a recording is in flight — the useHotkeyRecording hook owns the
register/unregister lifecycle. Settings + onboarding switch to a
parse-only validate command so picking a combo never holds the key
outside the recording window.

https://claude.ai/code/session_01AD2Gcj4j75xvaJb9oFpyCJ
Wires tauri-plugin-autostart into the Tauri builder (macOS Login Item
via AppleScript, Windows registry Run key, Linux .desktop file), grants
the capability set, and surfaces a Start at login toggle in both the
Hotkeys onboarding step and Settings → Recording. The frontend bindings
go through a small @/lib/autostart helper so component tests can mock
a single import path.

https://claude.ai/code/session_01AD2Gcj4j75xvaJb9oFpyCJ
Extends the macOS CGEventTap path to recognize two new shortcut surfaces
that tauri-plugin-global-shortcut can't express on its own:

* Modifier-only chord, e.g. Cmd+Opt — fires when the exact modifier
  set becomes held and nothing else has been pressed.
* Double-tap of a single modifier, e.g. tap Cmd twice — fires on the
  second press within ~350ms when the modifier has been the only key
  held both times.

Adds parse_modifiers_only / parse_double_tap so the JS combo string
("Cmd+Opt" or "DoubleTap+Cmd") routes through the existing
HotkeyCombo enum to a new MacOsChordTap. Non-macOS platforms return
a clear "macOS-only" error for these surfaces.

HotkeyInput grows a chord/double-tap detector behind a new
allowChord prop (default true). The cancel-hotkey input opts out
since its backend can't share the single chord tap.

https://claude.ai/code/session_01AD2Gcj4j75xvaJb9oFpyCJ
- Cover the new HotkeyCombo::ModifiersOnly / DoubleTap variants in
  MacOsFnTap::register so the match is exhaustive.
- Add a manual Debug impl on MacOsChordTap so tests can .unwrap_err()
  the construction Result (the Arc<dyn Fn> callback can't derive
  Debug; we render it as <callback>).

https://claude.ai/code/session_01AD2Gcj4j75xvaJb9oFpyCJ
@LeydenJar LeydenJar merged commit bcd9d97 into main May 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants